package edu.ccut.saturn.core;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

/**
 * 所有SaturnBundle中的Activitor都要继承此类<br>
 * 类中获取Saturn服务
 * @author TonyYan
 *
 */
public class SaturnActivator implements BundleActivator {

	public SaturnActivator() {
	}

	public final void start(BundleContext context) throws Exception {
		
		ServiceFactory.getBundleService().addBundle(context.getBundle());
		doStart(context);
	}

	public final void stop(BundleContext context) throws Exception {
		
		doStop(context);
		ServiceFactory.getBundleService().removeBundle(context.getBundle());
	}

	/**
	 * 当启动Bundles时需要加入某些操作,请重写此方法
	 * 
	 * @param context
	 */
	protected void doStart(BundleContext context) throws Exception {

	}

	/**
	 * 当停止bundles时需要加入某些操作,请重写此方法
	 * 
	 * @param context
	 */
	protected void doStop(BundleContext context) throws Exception {

	}

}
